<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a>首页</a>
        <a>教务</a>
        <a>班级管理</a>
        <a><cite>已结业课程</cite></a>
      </span>
    <a class="layui-btn layui-btn-xs layui-btn-small" style="float:right;margin-top: 10px;"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh"></i> </a>
</div>
<div id="wodekehu" class="x-body" class="clear:both;">
    <div class="layui-row"
         style="padding-left:20px;border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
        <div class="layui-form layui-col-md12 x-so layui-form-pane"  lay-filter="form-organization">
            <div class="layui-input-inline">
                <select name="campus_id" lay-verify="required" lay-search="">
                    <option value="">选择校区</option>
                    {volist name="campus" id="campu"}
                    <option value="{$campu.id}">{$campu.campus_name}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-input-inline">
                <select name="grades_name" lay-search="">
                    <option value=""></option>
                    {volist name="grade" id="vo"}
                    <option value="{$vo.grades_name}">{$vo.grades_name}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" style="width: auto;" placeholder="创建时间" name="grades_date" id="start">
            </div>
            <div class="layui-input-inline">
                <button class="layui-btn" id="search">
                    <i class="layui-icon layui-icon-search"></i>筛选</button>
                <button class="layui-btn layui-btn-danger" id="clear">
                    <i class="layui-icon"></i>重置</button>
            </div>
        </div>
    </div>


    <table class="layui-hide" id="LAY_table_user" lay-filter="table"></table>

</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>

    layui.use(['form','laydate','element', 'table', 'layer', 'laytpl'], function () {
        var $ = layui.$,
            form = layui.form,
            table = layui.table,
            element = layui.element,
            laydate = layui.laydate,
            layer = layui.layer;

        var loading = layer.load();
        var course_id = '{$course_id}';
        var campus_id = '{$campus_id}';
        //数据表格 方法级渲染
        var tableIns = table.render({
            elem: '#LAY_table_user'
            , url: '{:url("Grades/end_grades_course")}?course_id='+ course_id +'&campus_id='+campus_id
            , method: 'POST'
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'id', title: '班级ID', width: 100, sort: true, fixed: false, align: 'center'
                }, {field: 'course_id', title: '课程ID', width: 300, align: 'center'
                }, {field: 'grades_name', title: '班级名称',style:' color:#01AAED;font-weight: bold;', width: 400, align: 'center'
                }, {field: 'campus_name', title: '归属校区', width: 100, align: 'center'
                }, {field: 'room_id', title: '教室ID', width: 300, align: 'center'
                }, {field: 'course_name', title: '课程名称', width: 300, align: 'center'
                }, {field: 'teacher', title: '上课老师', width: 100, align: 'center'
                }, {field: 'headmaster', title: '班主任', width: 100, align: 'center'
                }, {field: 'assistant', title: '助教', width: 100, align: 'center'
                }, {field: 'class_start_date', title: '开班日期', width: 120, align: 'center'
                }, {field: 'class_end_date', title: '结业日期', width: 120, align: 'center'
                }, {field: 'holiday_status', title: '是否跳过节假日?', width: 150, align: 'center'
                }, {field: 'repeat_status', title: '重复类型(周/日)', width: 200, align: 'center'
                }, {field: 'project_num', title: '计划课次(次)', width: 150, align: 'center'
                }, {field: 'class_time_place', title: '上课时间', width: 400, align: 'center'
                }, {field: 'preoccupation', title: '预招人数(人)', width: 150, align: 'center'
                }, {field: 'already_class', title: '已排课次(次)', width: 150, align: 'center'
                }, {field: 'already_arranged', title: '上课进度(次)', width: 150, align: 'center'
                }, {field: 'remarks', title: '备注', width: 100, align: 'center'
                }, {field: 'status_text', title: '是否开班?', width: 100, align: 'center'
                }, {field: 'create_time', title: '创建时间', width: 200, align: 'center'
                }, {field: 'graduation_status', title: '结业状态', width: 100, align: 'center'
                }
            ]]
            , height: 'full-180'
            , page: true
            , done: function () {
                $("[data-field='id']").css('display','none');
                $("[data-field='course_id']").css('display','none');
                $("[data-field='room_id']").css('display','none');
                layer.close(loading);
            }
        });

        //日期
        laydate.render({
            elem: '#start',
            range: true
            ,trigger: 'click'
        });

        //搜索项
        $('#search').click(function () {
            var field = {};
            // field.status = $('select[name=status] option:selected').val();
            field.grades_name = $('select[name=grades_name]').val();
            field.campus_id = $('select[name=campus_id] option:selected').val();
            var create_date_rang = $('input[name=grades_date]').val();
            if(create_date_rang.length > 0){
                strs_date=create_date_rang.split("-"); //字符分割
                field.start_date = strs_date[0]+'-'+strs_date[1]+'-'+strs_date[2];
                field.end_date = strs_date[3]+'-'+strs_date[4]+'-'+strs_date[5];
            }

            console.log(field);
            tableIns.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });//清除
        $('#clear').click(function () {
            $('.layui-form-pane').find('.layui-input-inline').each(function (index, element) {
                $(element).find('input[type=text]').val('');
                $(element).find('select').val('');
            })
            tableIns.reload({
                where: {
                    'grades_name': '',
                    'grades_date':'',
                    'campus_id':''
                    // 'status': '',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });



    });
</script>